<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
        // 2.repeat ：可以重复某个字符；
        var str = "*";
        console.log( str.repeat(5));

        var str = "fdsafdsaa432a范德萨33发发范德萨";
        //    var res =  str.replace(/\d+/g,"***");
        // var res = str.replace(/\d+/g,function(arg){
        //     console.log(arg);
        //     return "*".repeat(arg.length);
        // })

        // var res = str.replace(/\d+/g,function(match){
        //     console.log(match);
        //     return "*".repeat(match.length);
        // })
        // console.log(res);

        var res = str.replace(/\d+/g,function(string){
            console.log(string);
            return "*".repeat(string.length);
        })
        console.log(res);

        var str = 'x-x_';
        var retArr = [];
        str.replace(/(x_*)|(-)/g, function(match, p1, p2) {
        if (p1) { retArr.push({ on: true, length: p1.length }); }
        if (p2) { retArr.push({ on: false, length: 1 }); }
        });

        console.log(retArr);
    </script>
</body>
</html>